package com.ebt.m.wiki;

import android.content.Context;
import android.util.AttributeSet;
import android.view.View;
import android.widget.TextView;

import com.ebt.m.R;
import com.ebt.m.data.bean.Brand;
import com.ebt.m.commons.buscomponent.listview.IView;

/**
 * Created by wanglu on 2017/10/18.
 */

public class SectionSearchMaybeBrand extends IView {
    TextView productName;
    TextView brandName;
    Brand brand;
    View content;

    public SectionSearchMaybeBrand(Context context, AttributeSet attrs, int defStyle) {
        super(context, attrs, defStyle);
        inflate(context, R.layout.product_search_maybe_brand, this);
        productName = findViewById(R.id.product_name);
        brandName = findViewById(R.id.brand_name);
        content = findViewById(R.id.content);

    }

    public SectionSearchMaybeBrand(Context context, AttributeSet attrs) {
        this(context, attrs, 0);
    }

    public SectionSearchMaybeBrand(Context context) {
        this(context, null);
    }

    @Override
    public void update(Object... args) {
        brand = (Brand) args[0];
        brandName.setText(brand.getBrandShortName());
        content.setOnClickListener(view -> {
            if (mOnclickListner != null)
                mOnclickListner.onClick(view, brand);
        });
        productName.setText(brand.getName());
    }

}
